package com.ojoin.trade.supplyloan_core.web.dao.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlLoanFloatDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlLoanFloat;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-1-29
 * Time: 上午10:20
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbSlLoanFloatDaoImpl extends BaseDaoImpl<TbSlLoanFloat> implements TbSlLoanFloatDao {
    @Override
    public List<TbSlLoanFloat> queryFloatVoByCreditId(int idOfCredit) throws BusinessException {
        String mapMethodName = "selectbycreditid";
        try {
            List list = this.sqlSessionTemplate.selectList(getSqlName(mapMethodName),
                    idOfCredit);
         return list;
        } catch (Exception e) {
            throw new DaoException(String.format("查询商户贷款差价浮动情况信息表出错->" + idOfCredit + "出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }

    }

    @Override
    public List<TbSlLoanFloat> queryMemoByCreditId(int idOfCredit) throws BusinessException {
        String mapMethodName = "selectmemobycreditid";
        try {
            List list = this.sqlSessionTemplate.selectList(getSqlName(mapMethodName),
                    idOfCredit);
            return list;
        } catch (Exception e) {
            throw new DaoException(String.format("查询商户贷款差价浮动情况信息表出错->" + idOfCredit + "出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
    }

    @Override
    public String queryAmountByCreditId(int idOfCredit) throws BusinessException {

        String mapMethodName = "selectsumflostbycreditid";
        try {
          String amount = this.sqlSessionTemplate.selectOne(getSqlName(mapMethodName),
                    idOfCredit);
            return amount;
        } catch (Exception e) {
            throw new DaoException(String.format("查询商户贷款差价浮动情况信息表出错->" + idOfCredit + "出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
    }

    @Override
    public List<TbSlLoanFloat> queryFloatByJoinid(int joinid) throws BusinessException {
        String mapMethodName = "selectbyjoinid";
        try {
            List<TbSlLoanFloat> list = this.sqlSessionTemplate.selectList(getSqlName(mapMethodName),
                    joinid);
            return list;
        } catch (Exception e) {
            throw new DaoException(String.format("查询商户贷款差价浮动情况信息表出错->" + joinid + "出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
    }


}
